package net.discard.model;

import net.discard.model.jy.enums.PowerEnum;
import net.discard.model.jy.enums.TopicEnum;
import net.discard.model.jy.enums.TypeEnum;
import net.discard.model.jy.enums.WeightEnum;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.ViewType;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.upms.model.base.HyperModel;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.util.Date;

/**
 * Created by liyuepeng on 2019-09-18.
 */
@Erupt(name = "活动管理",
        power = @Power(importable = true, export = true),
        orderBy = "id desc"
)
@Entity
@Table(name = "activity")
public class Activity extends HyperModel {

    @EruptField(
        views = @View(title = "活动标题"),
        edit = @Edit(
            title = "标题", notNull = true, inputType = @InputType, search = @Search(vague = true)
        )
    )
    private String title;

    @EruptField(
            views = @View(title = "图片"),
            edit = @Edit(
                    title = "图片", notNull = true, type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE))
    )
    private String image;

    @EruptField(
            views = @View(title = "开始时间"),
            edit = @Edit(title = "开始时间", notNull = true)
    )
    private Date startDate;

    @EruptField(
            views = @View(title = "活动天数"),
            edit = @Edit(title = "天数",
                    type = EditType.CHOICE, choiceType = @ChoiceType(
                    vl = {
                            @VL(label = "1", value = "1"),
                            @VL(label = "2", value = "2"),
                            @VL(label = "3", value = "3"),
                            @VL(label = "4", value = "4"),
                            @VL(label = "5", value = "5")
                    }
            ))
    )
    private int days;

    @EruptField(
        views = @View(title = "活动主题"),
        edit = @Edit(
            title = "主题", notNull = true,
            type = EditType.CHOICE, choiceType = @ChoiceType(fetchHandler = TopicEnum.class)
        )
    )
    private int topic;

    @EruptField(
        views = @View(title = "活动类型"),
        edit = @Edit(
            title = "类型", notNull = true,
            type = EditType.CHOICE, choiceType = @ChoiceType(fetchHandler = TypeEnum.class)
        )
    )
    private int type;

    @EruptField(
        views = @View(title = "适合年龄"),
        edit = @Edit(
            title = "适合年龄", notNull = true, inputType = @InputType
        )
    )
    private String age;

    @EruptField(
        views = @View(title = "活动强度"),
        edit = @Edit(
            title = "活动强度", notNull = true,
            type = EditType.CHOICE, choiceType = @ChoiceType(fetchHandler = PowerEnum.class)
        )
    )
    private int power;

    @EruptField(
        views = @View(title = "权重"),
        edit = @Edit(
            title = "权重", type = EditType.CHOICE,
            choiceType = @ChoiceType(fetchHandler = WeightEnum.class)
        )
    )
    private int weight;

    @EruptField(
        views = @View(title = "文章内容", type = ViewType.HTML, export = false),
        edit = @Edit(title = "内容", type = EditType.HTML_EDITOR,
                notNull = true, htmlEditorType = @HtmlEditorType(HtmlEditorType.Type.CKEDITOR)
        )
    )
    private String content;

    @CreatedDate
    public Date createTime;

    @LastModifiedDate
    public Date updateTime;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getTopic() {
        return topic;
    }

    public void setTopic(int topic) {
        this.topic = topic;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public int getDays() {
        return days;
    }

    public void setDays(int days) {
        this.days = days;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @Override
    public Date getCreateTime() {
        return createTime;
    }

    @Override
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public Date getUpdateTime() {
        return updateTime;
    }

    @Override
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
